package com.qf.controller;

import com.qf.entiy.Health;
import com.qf.entiy.Organ;
import com.qf.service.Impl.OrganServiceImpl;
import com.qf.service.OrganService;
import com.qf.util.Constants;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/*
    Dell
    2021/9/30
    13:13
*/
@WebServlet("/organ")
public class OrganController extends BaseController {
    public String showAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        OrganService organService = new OrganServiceImpl();
        List<Organ> organList = organService.showAllOrgan();
        request.setAttribute("organList",organList);
        return Constants.FORWARD+"/edit.jsp";
    }
    public String selectId(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        OrganService organService = new OrganServiceImpl();
        Health health = organService.selectId(Integer.valueOf(id));
        List<Organ> organList = organService.showAllOrgan();
        request.setAttribute("organList",organList);
        request.setAttribute("health",health);
        return Constants.FORWARD+"/edit.jsp";
    }
}
